package cn.com.yusys.yusp.mobile.web.rest;

import cn.com.yusys.yusp.admin.domain.WcrmAgriculturalSubjectVisitInfo;
import cn.com.yusys.yusp.admin.domain.WcrmMarketActivity;
import cn.com.yusys.yusp.admin.web.rest.CustCenterResource;
import cn.com.yusys.yusp.commons.excel.ExcelTaskManager;
import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import cn.com.yusys.yusp.mobile.service.CustomerMainBodyVisitService;
import cn.com.yusys.yusp.mobile.service.CustomerVisitService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/mobile/customerMainBody")
public class CustomerMainBodyVisitResource {

    @Resource
    CustomerMainBodyVisitService customerMainBodyVisitService;
    @Resource
    private ExcelTaskManager excelTaskManager;
    private String pojoClassName = WcrmAgriculturalSubjectVisitInfo.class.getName();
    private String exportSql = "queryAllByLimitMainBody";

    //新型农业经营主体走访列表查询
    @GetMapping("/getCustomerMainBodyVisitList")
    public ResultDto<Object> getCustomerVisitList(QueryModel queryModel) {
        return new ResultDto<>(customerMainBodyVisitService.getCustomerMainBodyVisitList(queryModel));
    }
    //新型农业经营主体走访明细
    @GetMapping("/getCustomerMainBodyDetail")
    public ResultDto<Object> getCustomerMainBodyDetail(QueryModel queryModel) {
        return new ResultDto<>(customerMainBodyVisitService.getCustomerMainBodyDetail(queryModel));
    }
    //更新新型农业经营主体走访明细
    @PostMapping("/updateCustomerMainBodyDetail")
    public ResultDto<Integer> updateCustomerMainBodyDetail(@RequestBody Map map) {
        return new ResultDto<>(customerMainBodyVisitService.updateCustomerMainBodyDetail(map));
    }
    //金融服务基本情况
    @GetMapping("/getFinanceDetail")
    public ResultDto<Object> getFinanceDetail(QueryModel queryModel) {
        return new ResultDto<>(customerMainBodyVisitService.getFinanceDetail(queryModel));
    }
    //更新金融服务基本情况
    @PostMapping("/updateFinanceDetail")
    public ResultDto<Integer> updateFinanceDetail(@RequestBody Map map) {
        return new ResultDto<>(customerMainBodyVisitService.updateFinanceDetail(map));
    }
    //经营财务信息
    @GetMapping("/getManageInfo")
    public ResultDto<Object> getManageInfo(QueryModel queryModel) {
        return new ResultDto<>(customerMainBodyVisitService.getManageInfo(queryModel));
    }
    //更新金融服务基本情况
    @PostMapping("/updateManageInfo")
    public ResultDto<Integer> updateManageInfo(@RequestBody Map map) {
        return new ResultDto<>(customerMainBodyVisitService.updateManageInfo(map));
    }

    //新型农业经营主体详情
    @GetMapping("/getCustomerMainBodyParticulars")
    public ResultDto<Object> getCustomerMainBodyParticulars(QueryModel queryModel) {
        return new ResultDto<>(customerMainBodyVisitService.getCustomerMainBodyParticulars(queryModel));
    }
    @GetMapping("/exportExcel")
    public ResultDto<String> exportExcel(QueryModel queryModel){
        CustCenterResource.judgeUserJurisdiction(queryModel, true);
        String taskId = excelTaskManager.addExcelExportTask(exportSql, null, queryModel, pojoClassName);
        return new ResultDto<>(taskId);
    }
}

